package com.ssm.web.config.filter;

import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import java.io.IOException;

/**
 * 不要在 Filter 里提前去 getInputStream()，否则 @RequestBody 将拿不到东西而报错
 * https://blog.csdn.net/f641385712/article/details/86554854
 */
@Order(2)
@Component
//@WebFilter(urlPatterns = "/*", asyncSupported = true)
public class TokenFilter implements Filter {

    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        filterConfig.getFilterName();
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        filterChain.doFilter(servletRequest, servletResponse);
    }

    @Override
    public void destroy() {
        System.out.printf("destory");
    }
}
